package com.zer0.tga.math;

import com.zer0.tga.art.Bitmap;
import com.zer0.tga.art.Screen;


public class BoundingBox {

	    public Box box;
	    public BoundingBoxOwner owner;

	    public BoundingBox(BoundingBoxOwner owner, Box box) {
	        this.owner = owner;
	        this.box = box;
	    }

	    public BoundingBox grow(double s) {
	    	Box newbox = new Box(this.box.x0 - s, this.box.y0 - s, this.box.x1 + s, this.box.y1 + s);
	        return new BoundingBox(this.owner, newbox);
	    }
	    

	    public boolean intersects(BoundingBox b) {
	        if (b.box.x0 >= box.x1 || b.box.y0 >= box.y1 || b.box.x1 <= box.x0 || b.box.y1 <= box.y0) 
	        	return false;
	        return true;
	    }
	    
	    public boolean intersects(Box b) {
	        if (b.x0 >= box.x1 || b.y0 >= box.y1 || b.x1 <= box.x0 || b.y1 <= box.y0) 
	        	return false;
	        return true;
	    }
	    
	    public boolean intersects(int x0, int y0, int x1, int y1) {
	    	 if (x0 >= box.x1 || y0 >= box.y1 || x1 <= box.x0 || y1 <= box.y0) 
	    		return false;
	    	return true;
	    }
	    
	    public void render(Screen screen) {
	        Bitmap b = new Bitmap(box.x1-box.x0,box.y1-box.y0);
	        b.clearWithColor(0x40808080);
	    	screen.draw(b,box.x0,box.y0,box.x1,box.y1);
	    }
}


